home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / patch12.zip / CONFIGUR.E < prev    next >
Text File  |  1990-05-30  |  32KB  |  1,422 lines

  1. #! /bin/sh
  2. #
  3. # If these # comments don't work, trim them.  Don't worry about any other
  4. # shell scripts, Configure will trim # comments from them for you.
  5. #
  6. # (If you are trying to port this package to a machine without sh, I would
  7. # suggest you cut out the prototypical config.h from the end of Configure
  8. # and edit it to reflect your system.  Some packages may include samples
  9. # of config.h for certain machines, so you might look for one of those.)
  10. #
  11. # $Header: Head.U,v 1.0 87/05/22 12:28:10 lwall Exp $
  12. #
  13. # Yes, you may rip this off to use in other distribution packages.
  14. # (Note: this Configure script was generated automatically.  Rather than
  15. # working with this copy of Configure, you may wish to get metaconfig.)
  16.  
  17. : sanity checks
  18. PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc:/usr/new:/usr/new/bin:/usr/nbin'
  19. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  20.  
  21. if test ! -t 0; then
  22.     echo "Say 'sh Configure', not 'sh <Configure'"
  23.     exit 1
  24. fi
  25.  
  26. (alias) >/dev/null 2>&1 && \
  27.     echo "(I see you are using the Korn shell.  Some ksh's blow up on Configure," && \
  28.     echo "especially on exotic machines.  If yours does, try the Bourne shell instead.)"
  29.  
  30. if test ! -d ../UU; then
  31.     if test ! -d UU; then
  32.     mkdir UU
  33.     fi
  34.     cd UU
  35. fi
  36.  
  37. case "$1" in
  38. -d) shift; fastread='yes';;
  39. esac
  40.  
  41. d_eunice=''
  42. eunicefix=''
  43. define=''
  44. loclist=''
  45. expr=''
  46. sed=''
  47. echo=''
  48. cat=''
  49. rm=''
  50. mv=''
  51. cp=''
  52. tail=''
  53. tr=''
  54. mkdir=''
  55. sort=''
  56. uniq=''
  57. grep=''
  58. trylist=''
  59. test=''
  60. inews=''
  61. egrep=''
  62. more=''
  63. pg=''
  64. Mcc=''
  65. vi=''
  66. mailx=''
  67. mail=''
  68. cpp=''
  69. Log=''
  70. Header=''
  71. bin=''
  72. cc=''
  73. contains=''
  74. cppstdin=''
  75. cppminus=''
  76. d_charsprf=''
  77. d_flexfnam=''
  78. d_index=''
  79. d_voidsig=''
  80. libc=''
  81. mansrc=''
  82. manext=''
  83. models=''
  84. split=''
  85. small=''
  86. medium=''
  87. large=''
  88. huge=''
  89. ccflags=''
  90. ldflags=''
  91. n=''
  92. c=''
  93. package=''
  94. registers=''
  95. reg1=''
  96. reg2=''
  97. reg3=''
  98. reg4=''
  99. reg5=''
  100. reg6=''
  101. reg7=''
  102. reg8=''
  103. reg9=''
  104. reg10=''
  105. reg11=''
  106. reg12=''
  107. reg13=''
  108. reg14=''
  109. reg15=''
  110. reg16=''
  111. spitshell=''
  112. shsharp=''
  113. sharpbang=''
  114. startsh=''
  115. voidflags=''
  116. defvoidused=''
  117. CONFIG=''
  118. : set package name
  119. package=patch
  120.  
  121. echo " "
  122. echo "Beginning of configuration questions for $package kit."
  123. : Eunice requires " " instead of "", can you believe it
  124. echo " "
  125.  
  126. define='define'
  127. undef='/*undef'
  128. libpth='/usr/lib /usr/local/lib /lib'
  129. smallmach='pdp11 i8086 z8000 i80286 iAPX286'
  130. rmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
  131. trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
  132.  
  133. : We must find out about Eunice early
  134. eunicefix=':'
  135. if test -f /etc/unixtovms; then
  136.     eunicefix=/etc/unixtovms
  137. fi
  138. if test -f /etc/unixtovms.exe; then
  139.     eunicefix=/etc/unixtovms.exe
  140. fi
  141.  
  142. attrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
  143. attrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
  144. attrlist="$attrlist ns32000 ns16000 iAPX286 mc300 mc500 mc700 sparc"
  145. attrlist="$attrlist nsc32000 sinix xenix venix posix ansi M_XENIX"
  146. attrlist="$attrlist $mc68k __STDC__"
  147. pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib /lib"
  148. d_newshome="../../NeWS"
  149. defvoidused=7
  150.  
  151. : some greps do not return status, grrr.
  152. echo "grimblepritz" >grimble
  153. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  154.     contains=contains
  155. elif grep grimblepritz grimble >/dev/null 2>&1 ; then
  156.     contains=grep
  157. else
  158.     contains=contains
  159. fi
  160. rm -f grimble
  161. : the following should work in any shell
  162. case "$contains" in
  163. contains*)
  164.     echo " "
  165.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  166.     cat >contains <<'EOSS'
  167. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  168. EOSS
  169. chmod +x contains
  170. esac
  171.  
  172. : first determine how to suppress newline on echo command
  173. echo "Checking echo to see how to suppress newlines..."
  174. (echo "hi there\c" ; echo " ") >.echotmp
  175. if $contains c .echotmp >/dev/null 2>&1 ; then
  176.     echo "...using -n."
  177.     n='-n'
  178.     c=''
  179. else
  180.     cat <<'EOM'
  181. ...using \c
  182. EOM
  183.     n=''
  184.     c='\c'
  185. fi
  186. echo $n "Type carriage return to continue.  Your cursor should be here-->$c"
  187. read ans
  188. rm -f .echotmp
  189.  
  190. : now set up to do reads with possible shell escape and default assignment
  191. cat <<EOSC >myread
  192. case "\$fastread" in
  193. yes) ans=''; echo " " ;;
  194. *) ans='!';;
  195. esac
  196. while expr "X\$ans" : "X!" >/dev/null; do
  197.     read ans
  198.     case "\$ans" in
  199.     !)
  200.     sh
  201.     echo " "
  202.     echo $n "\$rp $c"
  203.     ;;
  204.     !*)
  205.     set \`expr "X\$ans" : "X!\(.*\)\$"\`
  206.     sh -c "\$*"
  207.     echo " "
  208.     echo $n "\$rp $c"
  209.     ;;
  210.     esac
  211. done
  212. rp='Your answer:'
  213. case "\$ans" in
  214. '') ans="\$dflt";;
  215. esac
  216. EOSC
  217.  
  218. : general instructions
  219. cat <<EOH
  220.  
  221. This installation shell script will examine your system and ask you questions
  222. to determine how the $package package should be installed.  If you get stuck
  223. on a question, you may use a ! shell escape to start a subshell or execute
  224. a command.  Many of the questions will have default answers in square
  225. brackets--typing carriage return will give you the default.
  226.  
  227. On some of the questions which ask for file or directory names you are
  228. allowed to use the ~name construct to specify the login directory belonging
  229. to "name", even if you don't have a shell which knows about that.  Questions
  230. where this is allowed will be marked "(~name ok)".
  231.  
  232. EOH
  233. rp="[Type carriage return to continue]"
  234. echo $n "$rp $c"
  235. . myread
  236. cat <<EOH
  237.  
  238. Much effort has been expended to ensure that this shell script will run
  239. on any Unix system.  If despite that it blows up on you, your best bet is
  240. to edit Configure and run it again. Also, let me (lwall@jpl-devvax.jpl.nasa.gov)
  241. know how I blew it.  If you can't run Configure for some reason, you'll have
  242. to generate a config.sh file by hand.
  243.  
  244. This installation script affects things in two ways: 1) it may do direct
  245. variable substitutions on some of the files included in this kit, and
  246. 2) it builds a config.h file for inclusion in C programs.  You may edit
  247. any of these files as the need arises after running this script.
  248.  
  249. If you make a mistake on a question, there is no easy way to back up to it
  250. currently.  The easiest thing to do is to edit config.sh and rerun all the
  251. SH files.  Configure will offer to let you do this before it runs the SH files.
  252.  
  253. EOH
  254. rp="[Type carriage return to continue]"
  255. echo $n "$rp $c"
  256. . myread
  257.  
  258. : get old answers, if there is a config file out there
  259. if test -f ../config.sh; then
  260.     echo " "
  261.     dflt=y
  262.     rp="I see a config.sh file.  Did Configure make it on THIS system? [$dflt]"
  263.     echo $n "$rp $c"
  264.     . myread
  265.     case "$ans" in
  266.     n*) echo "OK, I'll ignore it.";;
  267.     *)  echo "Fetching default answers from your old config.sh file..."
  268.     tmp="$n"
  269.     ans="$c"
  270.         . ../config.sh
  271.     n="$tmp"
  272.     c="$ans"
  273.     ;;
  274.     esac
  275. fi
  276.  
  277. : find out where common programs are
  278. echo " "
  279. echo "Locating common programs..."
  280. cat <<EOSC >loc
  281. $startsh
  282. case \$# in
  283. 0) exit 1;;
  284. esac
  285. thing=\$1
  286. shift
  287. dflt=\$1
  288. shift
  289. for dir in \$*; do
  290.     case "\$thing" in
  291.     .)
  292.     if test -d \$dir/\$thing; then
  293.         echo \$dir
  294.         exit 0
  295.     fi
  296.     ;;
  297.     *)
  298.     if test -f \$dir/\$thing; then
  299.         echo \$dir/\$thing
  300.         exit 0
  301.     elif test -f \$dir/\$thing.exe; then
  302.         : on Eunice apparently
  303.         echo \$dir/\$thing
  304.         exit 0
  305.     fi
  306.     ;;
  307.     esac
  308. done
  309. echo \$dflt
  310. exit 1
  311. EOSC
  312. chmod +x loc
  313. $eunicefix loc
  314. loclist="
  315. expr
  316. sed
  317. echo
  318. cat
  319. rm
  320. tr
  321. grep
  322. "
  323. trylist="
  324. test
  325. Mcc
  326. cpp
  327. "
  328. for file in $loclist; do
  329.     xxx=`loc $file $file $pth`
  330.     eval $file=$xxx
  331.     eval _$file=$xxx
  332.     case "$xxx" in
  333.     /*)
  334.     echo $file is in $xxx.
  335.     ;;
  336.     *)
  337.     echo "I don't know where $file is.  I hope it's in everyone's PATH."
  338.     ;;
  339.     esac
  340. done
  341. echo " "
  342. echo "Don't worry if any of the following aren't found..."
  343. ans=offhand
  344. for file in $trylist; do
  345.     xxx=`loc $file $file $pth`
  346.     eval $file=$xxx
  347.     eval _$file=$xxx
  348.     case "$xxx" in
  349.     /*)
  350.     echo $file is in $xxx.
  351.     ;;
  352.     *)
  353.     echo "I don't see $file out there, $ans."
  354.     ans=either
  355.     ;;
  356.     esac
  357. done
  358. case "$egrep" in
  359. egrep)
  360.     echo "Substituting grep for egrep."
  361.     egrep=$grep
  362.     ;;
  363. esac
  364.